// 收集页面上的所有图片
function collectImages() {
  const images = document.getElementsByTagName('img');
  const imageUrls = [];
  
  for (let img of images) {
    // 过滤掉小图标和空src
    if (img.src && 
        img.src.startsWith('http') && 
        img.width > 50 && 
        img.height > 50) {
      imageUrls.push({
        url: img.src,
        width: img.width,
        height: img.height,
        alt: img.alt || '图片'
      });
    }
  }

  return imageUrls;
}

// 监听来自popup的消息
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.action === 'getImages') {
    sendResponse(collectImages());
  }
}); 